.code16
.text
    mov %cs, %ax
    mov %ax, %ds
    mov %ax, %es

    movw $msg, %ax
    movw %ax, %bp
	movw $0x17, %cx // length of string
	call print_string
	call load_stage2
	mov $513, %ax
	jmp %ax

set_video_mode:
	/* set video mode */
	mov $0x00, %ah // function number
	mov $0x03, %al
    int $0x10
    ret

print_string:
	/* print a string at %bp to screen */
	movb $0x13, %ah // function number
	movb $0x01, %al // string contains attributes
	movb $0x00, %bh // page number
	movb $0x07, %bl // attribute
	movw $0x0000, %dx // start position
	int $0x10
	ret
	
load_stage2:
	/* load stage2 beginning at sector 2 into memory */
	movb $0x1, %al // number of sector to read
	movb $0x2, %cl // sector number
	movb $0x0, %ch // cylinder number
	movb $0x0, %dh // head number
	movb $0x0, %dl // drive number
	movw $0x200, %bx // points to data buffer
	movb 0x02, %ah // function number
	int $0x13
	ret

msg:
	.ascii "loading stage1..."
.org 510
.word 0xaa55
stage2:
    movw $msg2, %ax
    movw %ax, %bp
	movw $0x17, %cx // length of string
    call print_string2
print_string2:
	/* print a string at %bp to screen */
	movb $0x13, %ah // function number
	movb $0x01, %al // string contains attributes
	movb $0x00, %bh // page number
	movb $0x07, %bl // attribute
	movw $0x0000, %dx // start position
	int $0x10
	ret
msg2:
	.ascii "loading stage2..."
.org 1022
.word 0xaa55

